import time


class BasePage:
    def __init__(self, driver=None):
        if not driver:
            # self.driver = "1223456789"
            # print("创建一个新的浏览器对象")
            from selenium import webdriver
            from selenium.webdriver.chrome.service import Service

            service = Service(executable_path=r"C:\Users\smile\PycharmProjects\WebUIFram\common\driver\chromedriver.exe")
            self.driver = webdriver.Chrome(service=service)
            self.driver.maximize_window()
            self.driver.get("https://deyunce:828123@mall.deyunce.com/")
            time.sleep(3)

        else:
            time.sleep(3)
            self.driver = driver
            print(f"复用之前的浏览器对象:  {self.driver}")


class MainPage(BasePage):
    def goto_login_page(self):
        return LoginPage(self.driver)


class LoginPage(BasePage):
    def goto_main_page(self):
        return MainPage(self.driver)


if __name__ == '__main__':
    MainPage().goto_login_page().goto_main_page()
